///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once

#ifndef __RenderQueueInvocation_H__
#define __RenderQueueInvocation_H__

#include "OgrePrerequisites.h"
#include "OgreRenderQueueSortingGrouping.h"
#include "OgreIteratorWrappers.h"

namespace Ogre {

	
	
	
	class _OgreExport RenderQueueInvocation : public MemAlloc_SceneCtrl
	{
	protected:
		/// Target queue group
		uint8 mRenderQueueGroupID;
		/// Invocation identifier - used in listeners
		String mInvocationName;
		/// Solids ordering mode
		QueuedRenderableCollection::OrganisationMode mSolidsOrganisation;
		/// Suppress shadows processing in this invocation?
		bool mSuppressShadows;
		/// Suppress OGRE's render state management?
		bool mSuppressRenderStateChanges;
	public:
		
		RenderQueueInvocation(uint8 renderQueueGroupID, 
			const String& invocationName = StringUtil::BLANK);
		virtual ~RenderQueueInvocation();

		/// Get the render queue group id
		virtual uint8 getRenderQueueGroupID(void) const { return mRenderQueueGroupID; }

		/// Get the invocation name (may be blank if not set by creator)
		virtual const String& getInvocationName(void) const { return mInvocationName; }

		
		virtual void setSolidsOrganisation(
			QueuedRenderableCollection::OrganisationMode org)  
		{ mSolidsOrganisation = org; }

		
		virtual QueuedRenderableCollection::OrganisationMode
			getSolidsOrganisation(void) const { return mSolidsOrganisation; }

		
		virtual void setSuppressShadows(bool suppress) 
		{ mSuppressShadows =  suppress; }

		
		virtual bool getSuppressShadows(void) const { return mSuppressShadows; }

		
		virtual void setSuppressRenderStateChanges(bool suppress) 
		{ mSuppressRenderStateChanges =  suppress; }

		
		virtual bool getSuppressRenderStateChanges(void) const { return mSuppressRenderStateChanges; }

		
		virtual void invoke(RenderQueueGroup* group, SceneManager* targetSceneManager);

		/// Invocation identifier for shadows
		static String RENDER_QUEUE_INVOCATION_SHADOWS;
	};


	/// List of RenderQueueInvocations
	typedef vector<RenderQueueInvocation*>::type RenderQueueInvocationList;
	typedef VectorIterator<RenderQueueInvocationList> RenderQueueInvocationIterator;

	
	class _OgreExport RenderQueueInvocationSequence : public MemAlloc_SceneCtrl
	{
	protected:
		String mName;
		RenderQueueInvocationList mInvocations;
	public:
		RenderQueueInvocationSequence(const String& name);
		virtual ~RenderQueueInvocationSequence();

		
		const String& getName(void) const { return mName; }

		
		RenderQueueInvocation* add(uint8 renderQueueGroupID, 
			const String& invocationName);

		
		void add(RenderQueueInvocation* i);

		
		size_t size(void) const { return mInvocations.size(); }

		
		void clear(void);

		
		RenderQueueInvocation* get(size_t index);

		
		void remove(size_t index);

		
		RenderQueueInvocationIterator iterator(void);


	};
	
	

}

#endif

